package xpn.business.fund_return.entity.decision;

import org.springframework.context.ApplicationContextException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

@Service
public class DecisionService {
    @Resource
    private DecisionDao decisionDao;

    public Decision save(Decision decision) {
        if (Objects.isNull(decision.getId())) {
            Decision exist = decisionDao.findAllByCaseId(decision.getCaseId());
            if (Objects.nonNull(exist)) {
                throw new ApplicationContextException("该表单已存在，请勿重复创建");
            }
        }
        //提出公共字段保存至FrCase
        return decisionDao.save(decision);
    }
}
